Skip to content

Fix fenrir issues across wolfEngine - #257

Open
aidangarske wants to merge 170 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-combined
Open

aidangarske wants to merge 170 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-combined

Conversation

@aidangarske

Copy link
Copy Markdown
Member

Description

Combines open PRs #232 to #256 into one PR. Each Fenrir finding keeps its own commit.

Correct AEAD context ownership and reinitialization (supersedes #232, 6 findings)

F-8341 - 927da9a - CCM context copies now reject shared ownership without changing the source context.

F-10135 - f0d5d91 - CCM now initializes its backend before key setup and tracks successful ownership.

F-8352 - e8e5141 - CCM teardown now releases owned AAD even when backend initialization has not completed.

F-8377 - ff11826 - CCM reinitialization now releases AAD before resetting its pointer.

F-10142 - 878b3f9 - CCM now tracks successful initialization direction and per-operation tag validity separately.

F-12248 - a6a4d09 - Explicit CCM reinitialization now leaves spent TLS dispatch state while retaining per-record header requirements.

Release ECDSA result construction temporaries (supersedes #233, 1 finding)

F-10133 - a5b3492 - Failed ECDSA result construction now frees r and s BIGNUMs whose ownership was not transferred.

Correct engine PBE and MAC ownership (supersedes #234, 31 findings)

F-11322 - e174acb - MAC signing now checks the caller's output capacity before writing the result.

F-8348 - 2e2353b - HMAC raw-key export now checks the caller's output capacity.

F-13713 - f08d644 - HMAC now reports its maximum output size.

F-8344 - 2dc304c - MAC updates now reject input lengths that exceed the backend's supported range.

F-6450 - 566054e - CMAC context copying now reports failures accurately.

F-6451 - 5e0d8f2 - CMAC key setup now checks whether key assignment succeeds.

F-8374 - 0320dd0 - CMAC ASN.1 method registration now commits only after setup succeeds.

F-10159 - 1d3c456 - MAC keys are now cleansed before their storage is released.

F-12249 - d04d76c - Legacy CMAC keys now retain the correct free dispatch.

F-11327 - a1bf09e - MAC ASN.1 methods now retain engine-owned lifetime management.

F-13040 - 029ca20 - CMAC now rejects unsupported cipher selections.

F-8347 - b674fa5 - MAC state is now cleansed before release.

F-8392 - fda6a87 - MAC context duplication now skips keys that are not present.

F-11325 - a552924 - Failed MAC key replacement now preserves the existing key.

F-11329 - c4a224a - HMAC now preserves the original key length.

F-8382 - f1d686f - Failed MAC context copies now release partially constructed state.

F-11331 - 153ad83 - HMAC alignment buffers are now cleansed after use.

F-12250 - 0bd0f15 - Failed HMAC initialization now cleans up its partial state.

F-8351 - 71a281f - ECDSA digest registration now uses matching feature guards.

F-8368 - 3c07564 - PBE registration no longer depends on ECC being enabled.

F-8379 - c8e6277 - ECDSA teardown now uses feature guards consistent with initialization.

F-8390 - 7e9bedd - The duplicate FIPS callback definition has been removed.

F-11311 - c8b70de - Engine teardown now clears released PKEY method pointers.

F-12258 - 74d1f94 - Mutex initialization failures now produce the correct diagnostic.

F-8375 - f7bc653 - Legacy PBKDF2 setup now validates its parameters.

F-10147 - 0655cb1 - Engine binding now requires an exact engine identifier.

F-10148 - 880ae1a - Failed engine binding now rolls back initialized state.

F-11333 - 55fa31b - Engine binding and destruction now serialize their shared lifecycle state.

F-13063 - a3ac1d5 - Process-global PBE callbacks now retain the module lifetime they require.

F-10134 - 89cb1a4 - MAC ASN.1 key setup now checks key-assignment results.

F-5449 - 328edcc - MAC string controls now handle the supported control operations.

Correct AES CBC HMAC initialization and TLS records (supersedes #235, 14 findings)

F-9347 - c5bb9a2 - AES-CBC-HMAC documentation now states the correct IV length.

F-10143 - d48a14e - AES-CBC-HMAC now supports staged key and IV initialization.

F-13041 - 039ee8a - Non-TLS AES-CBC-HMAC encryption no longer updates the TLS HMAC state.

F-8366 - 5b33428 - AES-CBC-HMAC now returns backend encryption failures to the caller.

F-10140 - b03d001 - AES-CBC-HMAC controls now return standard error results.

F-13037 - ab76ec8 - TLS CBC-HMAC state now tracks empty records.

F-13039 - feeec16 - AES-CBC-HMAC now resets TLS framing state between operations.

F-10131 - e195543 - AES-CBC-HMAC cleanup now releases its cipher state.

F-11326 - 9f9f839 - CBC-HMAC now rejects malformed record lengths.

F-11308 - 6716d7f - CBC-HMAC no longer performs TLS authentication checks for non-TLS operations.

F-11309 - f71917c - CBC-HMAC TLS decryption now accepts extended padding.

F-13711 - ffc3dd1 - Invalid CBC-HMAC padding no longer corrupts the retained cipher state.

F-13067 - a2f39f9 - CBC-HMAC now cleanses the temporary record MAC before returning.

F-4172 - 49b9843 - CBC-HMAC TLS authentication now balances the authentication work across padding cases.

Balance DH and ECDH global RNG ownership (supersedes #236, 1 finding)

F-8345 - be5b62c - DH and ECDH now release global RNG locks only after successful acquisition.

Correct unsupported PKEY control results (supersedes #237, 1 finding)

F-15141 - 7bf6b11 - Unknown PKEY controls now return -2 while recognized controls retain their existing behavior.

Correct EC verification setup error reporting (supersedes #238, 2 findings)

F-11319 - 3303bf5 - EC_KEY verification now reports curve and key setup failures as operational errors.

F-12252 - 7a81843 - EVP EC verification now reports context and key setup failures as operational errors.

Correct legacy EC key operation cleanup (supersedes #239, 7 findings)

F-6182 - 9756b3a - Legacy ECDH now clears its temporary shared secret.

F-8381 - fc22f2f - Legacy EC cleanup now tracks key initialization before RNG setup.

F-10132 - 1faf160 - ECDH cleanup now tracks key initialization before RNG setup.

F-11305 - 61cf05c - Legacy ECDH documentation now identifies the output parameter correctly.

F-12287 - ca49b04 - EC signature capacity is now derived from the key.

F-13708 - e2aab87 - EC signature-length logging now uses the correct format.

F-13712 - 3a2c506 - Legacy ECDH KDF failures now produce the correct diagnostic.

Correct AES CCM cipher state and results (supersedes #240, 4 findings)

F-6452 - b957a66 - AES-CCM failures now produce the correct diagnostic.

F-11321 - b8d6206 - AES-CCM now uses the standard default tag size.

F-10136 - 4598615 - Empty AES-CCM updates now report zero output.

F-13038 - 2871f92 - AES-CCM decryption now preserves its nonce.

Correct EC derivation and control contracts (supersedes #241, 11 findings)

F-6630 - 3dba458 - ECDH now cleanses the raw shared secret after KDF processing.

F-8371 - f86ac06 - ECDH peer replacement now resets cached peer state.

F-8372 - 5652754 - ECDH derivation now rejects contexts without a peer key.

F-8373 - ffa1a43 - EC operations now propagate curve-size lookup failures.

F-10152 - dbb9318 - EC derivation now resolves the curve before applying policy checks.

F-11310 - 23eaa15 - ECDH KDF controls now return the configured output length.

F-11328 - c5dec39 - ECDH now validates peer groups and point encodings.

F-12288 - 187dd9d - ECDH now validates KDF configuration before derivation.

F-13048 - 6af1b25 - EC string controls now require exact control-name matches.

F-8362 - 74f4370 - ECDH derivation now reports the KDF output length actually written.

F-15139 - 84d172e - EC parameter string controls now support named curves.

Correct EC context ownership and initialization (supersedes #242, 4 findings)

F-4178 - 7c8e54f - ECC cleanup now releases RNG state only after successful initialization.

F-6175 - 77c0291 - EC context cleanup now releases owned ECDH KDF user keying material.

F-12251 - 649a1d1 - Failed curve-specific EC initialization now cleans up partially initialized state.

F-8361 - e76e5f0 - EC context copies now own their state independently.

Correct RSA PKEY controls and key ownership (supersedes #243, 9 findings)

F-6632 - 1cc8058 - RSA signing now checks for context data before accessing the configured digest.

F-10128 - f7ca1d5 - RSA encryption documentation now identifies the output parameter correctly.

F-10129 - c6be5c0 - RSA decryption documentation now identifies the output parameter correctly.

F-13042 - e4ebf06 - RSA controls now distinguish invalid arguments from unsupported operations.

F-6176 - 007d227 - RSA key generation now preserves the full-width public exponent.

F-15138 - c37bc88 - RSA key generation now releases transferred exponent storage.

F-8342 - bb4c5d9 - RSA digest encoding now checks its bounds on every supported OpenSSL version.

F-8364 - 4dbdb53 - RSA OAEP now honors the caller's label and manages its ownership correctly.

F-15135 - 5191279 - RSA verify-recovery controls now return the configured digest.

Correct DH parameter and derive handling (supersedes #244, 8 findings)

F-8365 - e622c82 - Named DH groups now preserve an absent q parameter.

F-10145 - 9c7621a - DH now releases the RNG mutex only after successful locking.

F-11318 - 72cc68a - Padded DH derivation now writes a modulus-sized result.

F-12253 - e8fc300 - DH padding controls now normalize their input consistently.

F-12255 - 57b7dfc - DH parameter refresh now clears a stale q value.

F-12290 - 080c651 - DH parameter generation now verifies the generated generator.

F-13043 - b229743 - DH now allocates the correct object size, with an isolated allocation-test fixture.

F-13068 - f58c10e - Legacy DH parameter handling now validates prime lengths.

Correct digest context and method handling (supersedes #245, 7 findings)

F-9350 - 5327ac4 - Generic digest documentation now describes the implementation correctly.

F-8378 - a671c52 - The direct SHA-1 method now uses the correct identifier.

F-10137 - 3e93ddb - The ECDSA SHA-1 method now reports the correct block size.

F-8367 - bff0059 - Failed digest method initialization now clears released global pointers.

F-13065 - ae94e50 - Digest alignment buffers are now cleansed after use.

F-8343 - 204006a - Oversized digest updates are now processed in backend-sized chunks.

F-10155 - 432dd5a - Generic digest context copies now own independent backend state.

Correct AES GCM lifecycle and error handling (supersedes #246, 5 findings)

F-12286 - 0dae312 - Legacy AES-GCM methods now register their cleanup callback.

F-10158 - bdc98ef - AES-GCM now bounds accumulated AAD lengths.

F-12289 - 899636d - AES-GCM backend failures now reach the OpenSSL error queue.

F-13055 - dd9d483 - AES-GCM control documentation now describes pointer directions correctly.

F-13709 - a032e40 - AES-GCM logging now uses formats matching its length types.

Fix AES CTR context and output handling (supersedes #247, 3 findings)

F-8376 - 94f9847 - Empty AES-CTR input now reports zero output.

F-9346 - 0ccbdb8 - AES-CTR documentation now states the correct IV length.

F-10146 - 45139c6 - AES-CTR now manages backend initialization and cleanup consistently.

Fix random generator state handling (supersedes #248, 4 findings)

F-10144 - ac415dd - RAND seeding now returns seed-mixing failures.

F-10160 - 5cb5fe5 - RAND status now reports whether initialization actually succeeded.

F-11332 - c19d664 - RAND cleanup now clears supplemental seed state.

F-13710 - 080b2d8 - RAND entropy logging now formats its floating-point value correctly.

Fix AES block cipher lifecycle and results (supersedes #249, 5 findings)

F-8383 - ac4bcaf - AES block cipher operations now return zero on failure.

F-9345 - 1bc2447 - AES-CBC documentation now states the correct IV length.

F-10149 - a4c1612 - AES block cipher contexts now manage backend initialization and cleanup consistently.

F-13046 - 6f6cf11 - AES-CBC initialization no longer contains a redundant guard.

F-13047 - e0b2566 - AES-ECB decryption no longer contains redundant conditions.

Correct DES3 cipher lifecycle and IV handling (supersedes #250, 3 findings)

F-8358 - b50670f - DES3 now limits IV copies to the IV state being transferred.

F-8389 - 4ab3ba5 - DES3 decryption failures now produce the correct diagnostic.

F-10150 - e372bad - DES3 cleanup now releases initialized cipher state.

Fix legacy OpenSSL method and EC key handling (supersedes #251, 3 findings)

F-8384 - 51062b2 - Legacy method allocation now rejects missing method names.

F-8385 - 89ab490 - Legacy EC key handling now rejects keys without a private scalar.

F-13707 - 430fcd2 - Legacy EC private scalars now use padded encodings.

Correct TLS PRF state and output handling (supersedes #252, 4 findings)

F-8356 - a2761a4 - TLS PRF now rejects unsupported digest selections.

F-10138 - 78be9f6 - Failed TLS PRF secret setup now clears stale secret state.

F-12257 - 79c4c9b - TLS PRF now rejects oversized output lengths.

F-12269 - c82e94c - TLS PRF documentation now describes output parameter directions correctly.

Correct RSA method padding and lifecycle handling (supersedes #253, 13 findings)

F-8360 - 7c72f41 - RSA X9.31 signing now preserves the required signature width.

F-13064 - 0b0ea57 - RSA X9.31 operations now use the actual produced width.

F-6012 - d2e2cf5 - RSA X9.31 operations now report multiprecision failures.

F-11314 - 1bab7c1 - RSA X9.31 operations now report size errors.

F-11320 - 45cbc9c - RSA PSS operations now preserve the configured salt length.

F-15137 - 5585ccd - RSA PSS salt-mode conversion now preserves the selected mode.

F-8370 - 0845e67 - RSA cleanup no longer unlocks an RNG mutex that was not acquired.

F-12254 - 8a56082 - RSA operations now report RNG mutex lock failures.

F-6453 - d92f630 - RSA X9.31 operations now lock access to the global RNG.

F-8380 - 925df9f - RSA public-key import now rejects negative encoding lengths.

F-11306 - e7c1c65 - RSA private-key import documentation now describes the implementation correctly.

F-11313 - fb3acf6 - RSA private-key import now rejects negative encoding lengths.

F-13066 - c714db5 - RSA method handling no longer contains an unreachable digest check.

Correct HKDF state and output handling (supersedes #254, 7 findings)

F-6183 - e3c174b - HKDF extract mode now supports output-size queries.

F-8350 - d4560b4 - Failed HKDF key setup now clears stale key state.

F-10139 - dc00503 - Failed HKDF salt setup now clears stale salt state.

F-11312 - 0b3a82c - HKDF now rejects unsupported digest selections.

F-12256 - d3229f8 - HKDF now rejects oversized output requests.

F-13044 - 8ac69dd - HKDF now accepts empty keys.

F-15140 - 3b827ff - HKDF key setup now preserves previously configured info.

Correct AES CCM control validation (supersedes #255, 8 findings)

F-13056 - cf5590b - AES-CCM control documentation now describes pointer directions correctly.

F-11323 - f43824b - AES-CCM controls now reject undersized nonces.

F-10130 - 8422d0e - The AES-CCM IV-length getter comment now describes the actual result.

F-11317 - 8473507 - AES-CCM fixed-IV setup now rejects null input.

F-11324 - 9e19c04 - AES-CCM controls now validate tag parameters.

F-8391 - 2a89278 - AES-CCM documentation no longer claims unsupported IV generation.

F-9348 - 6de8e01 - AES-CCM documentation no longer claims unsupported SET_IV handling.

F-10141 - b52e472 - AES-CCM SET_L validation now removes a redundant condition while retaining its stricter lower bound.

Add X9.31 RSA signature leading zero regression test (supersedes #256)

99b1846 - Adds a test that signs a message whose X9.31 signature starts with a zero byte and checks the wolfEngine output against OpenSSL. The left-pad fix from #256 is already covered by F-8360 and F-13064, so only the test is carried over.

@aidangarske aidangarske self-assigned this Nov 9, 2026
Copilot AI balanced review requested due to automatic review settings November 9, 2026 18:35
@aidangarske

Copy link
Copy Markdown
Member Author

@claude review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The Windows test project omits a required source file, causing unresolved references with OpenSSL 1.0.2, while logging-observer helpers introduce races and spurious failures in multithreaded debug tests.

2 open issues
What changed in this PR

Consolidates Fenrir fixes across wolfEngine’s OpenSSL integration, improving cryptographic context ownership, lifecycle handling, input validation, and error reporting.

Changes:

  • Corrects cipher, key-derivation, RNG, and engine lifecycle behavior.
  • Adds regression tests for cleanup, compatibility, output bounds, and engine loading.
  • Updates build checks, legacy OpenSSL test patches, and documentation.
File Description
test/​unit.h Declares new regression tests and memory-check helpers.
test/​unit_static.test Runs the unit suite with static engine loading.
test/​test_tls1_prf.c Tests digest rejection, secret failures, and output bounds.
test/​test_rand.c Tests RNG cleanup, status, and logging.
test/​test_pbe.c Corrects parameter fixtures and checks PBE registration.
test/​test_pbe_lifetime.c Tests callback ownership across engine release and reload.
test/​test_openssl_bc.c Adds legacy method and EC encoding tests.
test/​test_engine_lifetime.c Tests repeated dynamic loading and unloading.
test/​test_ecc.c Tests context copying, derivation controls, and signature validation.
test/​test_digest.c Tests digest copying, identifiers, and HMAC context reuse.
test/​test_dh_alloc.c Adds isolated DH allocation tracking.
test/​test_cmac_compat.c Tests cleanup across CMAC backend layouts.
test/​rsa_oaep_allocator.sh Checks OAEP allocator usage.
test/​include.am Registers new test sources and executables.
test/​engine_bind.test Runs engine binding lifecycle checks.
test-openssl-version.sh Adds DH allocation testing to version checks.
src/​we_wolfengine.c Checks binding availability before engine creation.
src/​we_tls_prf.c Validates digest and output requests; resets secret state.
src/​we_random.c Synchronizes seed cleanup and reports initialization status.
src/​we_pbe.c Retains callback module lifetime and validates legacy parameters.
src/​we_openssl_bc.c Adds compatibility callbacks and padded EC private-key encoding.
src/​we_internal.c Serializes engine lifecycle and handles rollback and cleanup.
src/​we_hkdf.c Corrects parameter reset, empty keys, and output handling.
src/​we_dh.c Corrects parameter handling, RNG unlocking, and secret padding.
src/​we_des3_cbc.c Adds independent copying and cleanup; bounds IV transfers.
src/​we_cmac_compat.h Provides backend-compatible CMAC cleanup.
src/​we_aes_gcm.c Adds cleanup, copy rejection, AAD bounds, and error reporting.
src/​we_aes_ctr.c Adds independent copying and cleanup; fixes empty-input results.
src/​we_aes_ccm.c Corrects ownership, reinitialization, tags, and control validation.
src/​include.am Includes the private CMAC compatibility header.
README.md Documents the FIPS legacy DH parameter-generation restriction.
openssl_patches/​1.1.1b/​tests/​pkey_meth_kdf_test_111b.patch Initializes TLS PRF MAC output capacities.
openssl_patches/​1.1.1b/​tests/​fips/​dhtest_111b.patch Tests FIPS rejection of legacy DH parameter generation.
openssl_patches/​1.0.2h/​tests/​ssltest_102h.patch Initializes legacy TLS PRF MAC output capacities.
openssl_patches/​1.0.2h/​tests/​fips/​dhtest_102h.patch Updates legacy DH tests for FIPS restrictions.
Makefile.am Registers static-loading and binding test wrappers.
include/​wolfengine/​we_openssl_bc.h Declares legacy digest-copy and cipher-cleanup interfaces.
include/​wolfengine/​we_logging.h Adds compiler format checking for verbose logging.
include/​wolfengine/​we_internal.h Declares lifecycle, RNG, PBE, and MAC helpers.
configure.ac Detects module-pinning and backend compatibility capabilities.
.gitignore Excludes generated test binaries and results.

Review effort: Balanced

Comment thread test/test_openssl_bc.c Resolved
Comment thread test/test_rand.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #257

Scan targets checked: wolfengine-src, wolfengine-bugs
Not reviewed (no scan target covers them): .gitignore, Makefile.am, README.md, configure.ac, openssl_patches/1.0.2h/tests/fips/dhtest_102h.patch, openssl_patches/1.0.2h/tests/ssltest_102h.patch, openssl_patches/1.1.1b/tests/fips/dhtest_111b.patch, openssl_patches/1.1.1b/tests/pkey_meth_kdf_test_111b.patch, src/include.am, src/we_cmac_compat.h, test-openssl-version.sh, test/engine_bind.test, test/include.am, test/rsa_oaep_allocator.sh, test/unit.h, test/unit_static.test
Coverage: 40 of 40 in-scope changed file(s) opened by the reviewer

Findings: 4
4 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Max

Comment thread test/test_ecc.c Resolved
Comment thread src/we_aes_cbc_hmac.c Resolved
Comment thread test/test_rand.c Resolved
Comment thread src/we_mac.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A failed initial PBE registration leaves the PBKDF2 callback installed while initialization remains incomplete, breaking valid OpenSSL PBES2 operations until a later bind succeeds.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Restore PBKDF2 callback if PBE registration fails

src/​we_pbe.c:697

If the final PBE registration fails during the first bind, the already-installed PBKDF2 callback remains in OpenSSL's process-global registry while we_pbe_ready stays zero. Valid PBES2 operations then fail even without wolfEngine, until another bind succeeds. Preserve the previous callbacks and restore them on failure, or delegate to them until registration commits, so a failed engine load does not disable existing OpenSSL PBE functionality.

2 resolved since last review

Review effort: Balanced

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #257

Scan targets checked: wolfengine-src, wolfengine-bugs
Not reviewed (no scan target covers them): .gitignore, Makefile.am, README.md, configure.ac, openssl_patches/1.0.2h/tests/fips/dhtest_102h.patch, openssl_patches/1.1.1b/tests/fips/dhtest_111b.patch, src/include.am, src/we_cmac_compat.h, test-openssl-version.sh, test/engine_bind.test, test/include.am, test/rsa_oaep_allocator.sh, test/unit.h, test/unit_static.test, windows/test.vcxproj, windows/test.vcxproj.filters
Coverage: 38 of 40 in-scope changed file(s) opened by the reviewer; not opened: include/wolfengine/we_internal.h, include/wolfengine/we_openssl_bc.h

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 9, 2026 22:43

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@aidangarske
aidangarske force-pushed the fenrir-fixes-combined branch from 1f47c26 to 65d7f57 Compare November 10, 2026 21:01
Comment thread src/we_random.c
void we_rand_clear_seed(void)
{
#if !defined(WE_SINGLE_THREADED) && defined(WOLFSSL_ATOMIC_OPS)
we_rand_lock_seed_state();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't the mutex lock below good enough?

Comment thread src/we_aes_gcm.c
aes->tagLen, aes->aad, aes->aadLen);
if (ret != 0) {
WOLFENGINE_ERROR_FUNC(WE_LOG_CIPHER, "wc_AesGcmDecrypt", ret);
we_aes_gcm_set_error("decryption failed");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI says this path can be treated as normal by callers (eg. due to wrong key used), and that the set_error call puts an error in the queue. Worth investigating

Comment thread src/we_digest.c
WOLFENGINE_ERROR_MSG(WE_LOG_DIGEST, "digest was NULL");
ret = 0;
}
else if ((src->hashType == 0) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI says there is an issue here when copying a context after calling "final" because src->hashType is zero and falls to the BAD_FUNC_ARG at line 1044. Can you add a test case to check it out?

Comment thread src/we_dh.c
engineDh->primeLen = primeLen;
/* Generate the parameters with wolfSSL and copy into OpenSSL object. */
ret = we_dh_paramgen_int(dh, engineDh);
engineDh = (we_Dh *)DH_get_ex_data(dh, WE_DH_EX_DATA_IDX);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this path calls a few OpenSSL functions, meanwhile the EVP path still uses wolfCrypt. Consider unifying

Comment thread src/we_aes_gcm.c
ret = (int)len;
/* Resize stored AAD and append new data. */
newLen = (size_t)aes->aadLen + len;
p = (unsigned char*)OPENSSL_realloc(aes->aad, newLen);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to apply this change to CCM too?

Comment thread src/we_dh.c
BN_free(q);
BN_free(p);
DH_free(params);
#endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you add a comment about which #if is being closed for blocks this long? Eg:

#endif /* HAVE_FIPS */ 

Comment thread src/we_mac.c
/* Get key into cache. */
ret = we_mac_cache_key(ctx, mac);
#ifdef HAVE_FIPS
if ((ret == 1) && (mac->keySz < HMAC_FIPS_MIN_KEY)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI says there's no test for the min hmac size. Seems important. Can you check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants